package edu.kaist.cs442.client.android.common.pushutil.broadcast;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.util.Log;
import edu.kaist.cs442.client.android.common.RestServices;
import edu.kaist.cs442.client.android.common.location.track.TrackService;
import edu.kaist.cs442.client.android.common.pushutil.register.TrackInstallation;
import edu.kaist.cs442.server.locationalpush.push.c2dm.MessageVO;
import org.codehaus.jackson.map.PropertyNamingStrategy;

import java.util.UUID;

/**
 * Created with IntelliJ IDEA.
 * User: duyleekun
 * Date: 4/19/12
 * Time: 12:34 AM
 * To change this template use File | Settings | File Templates.
 */
public class Broadcast extends AsyncTask<Context,Void,Void> {
	@Override
	protected Void doInBackground(Context... contexts) {
		Log.i("location","broadcasting ....");
		MessageVO message = new MessageVO(UUID.randomUUID().toString());
		message.put("tickerText", "Help me!");
		message.put("contentTitle", "Help me!");
		message.put("contentText", "Help me!");

		Location lastLocation = ((LocationManager) contexts[0].getSystemService(Context.LOCATION_SERVICE)).getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

		RestServices.getPushSVC().sendNearby(message,lastLocation.getLatitude(),lastLocation.getLongitude(),0.01);
		return null;
	}
}
